<template>
  <div>
    <h2>当前求和为:{{ $store.state.sum }}</h2>
    <h4>当前求和放大100倍后:{{$store.getters.bigSum}}</h4>
    <select v-model.number="number">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>&nbsp;
    <button @click="increment">+</button>&nbsp;
    <button @click="decrement">-</button>&nbsp;
    <button @click="incrementOdd">和为奇数时再+</button>&nbsp;
    <button @click="incrementWait">等500毫秒再+</button>

  </div>
</template>

<script>
export default {
  name: 'Count',
  data() {
    return {

      number: 1
    }
  },
  methods: {
    increment() {
    this.$store.commit('JIA',this.number)
    },
    decrement() {
      this.$store.commit('JIAN',this.number)
    },
    incrementOdd() {
      this.$store.dispatch('jiaOdd',this.number)
    },
    incrementWait() {
    setTimeout(()=>{
      this.$store.dispatch('jiaWait',this.number)
    },500)
    }
  }
}
</script>

<style scoped>

</style>